Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: break out request helpers into new classes from app.py #99

Closed
wants to merge 1 commit into from

Conversation

drduhe
Copy link
Collaborator

@drduhe drduhe commented Oct 7, 2024

Issue #, if available: n/a

WIP

Notes

This PR introduces refactoring of the ImageRequestHandler and RegionRequestHandler classes to decouple them from ModelRunner. The handlers now accept their necessary dependencies through their constructors, making them self-contained, modular, and easier to test. Additionally, changes to the ModelRunner class were made to initialize these handlers with the appropriate dependencies.

Key Changes:

  1. Decoupled ImageRequestHandler from ModelRunner:

    • ImageRequestHandler now takes in the following dependencies via its constructor:
      • job_table, image_status_monitor, endpoint_statistics_table
      • tiling_strategy, region_request_queue, region_request_table
      • endpoint_utils, config
      • Functional parameters for feature selection, property addition, sinking features, and generating metrics.
    • This eliminates the direct dependency on the ModelRunner instance and improves modularity.
  2. Decoupled RegionRequestHandler from ModelRunner:

    • RegionRequestHandler now takes in its own initialization parameters:
      • region_request_table, job_table, region_status_monitor, endpoint_statistics_table
      • tiling_strategy, region_request_queue, endpoint_utils, config
    • This similarly decouples it from ModelRunner, allowing for cleaner design and unit testing.
  3. Updated ModelRunner to Inject Dependencies:

    • ModelRunner now constructs and passes all required dependencies to both ImageRequestHandler and RegionRequestHandler.
  4. Improved Modular Design and Testability:

    • By passing in functional dependencies and tables as constructor parameters, the handlers are more modular and easier to test in isolation.
  5. Renamed app.py and app_config`` files

    • Renamed app.py to model_runner.py
    • Renamed app_config.py to config.py

Checklist

Before you submit a pull request, please make sure you have the following:

  • Code changes are compact and well-structured to facilitate easy review
  • Changes are documented in the README.md and other relevant documentation pages
  • PR title and description accurately reflect the changes and are detailed enough for historical tracking
  • PR contains tests that cover all new code and the code has been manual tested
  • All new dependencies are declared (if any), and no unnecessary libraries are added
  • Performance impacts (if any) of the changes are evaluated and documented
  • Security implications of the changes (if any) are reviewed and addressed
  • I have read the Contributing Guidelines and agree to follow the Code of Conduct

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@drduhe drduhe force-pushed the refactor/setup-request-handlers branch 9 times, most recently from f43c63e to c63d878 Compare October 7, 2024 22:20
@drduhe drduhe force-pushed the refactor/setup-request-handlers branch from c63d878 to 42cacdd Compare October 8, 2024 15:52
@drduhe drduhe closed this Oct 8, 2024
@drduhe drduhe deleted the refactor/setup-request-handlers branch October 18, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant